home *** CD-ROM | disk | FTP | other *** search
- #include <ListMgr.h>
- #include <DialogMgr.h>
- #include <MemoryMgr.h>
- #include <QuickDraw.h>
-
- #include "MacCalc.h"
- #include "SheetHndlg.h"
- #include "CalcData.h"
- #include "Parser.h"
-
- #define ENTER_BUTTON 1
- #define CANCEL_BUTTON 2
- #define DATA_ITEM 4
-
- void EnterData( cell, sheet_record_hdl )
- Cell cell ;
- SHEET_WIN_HDL sheet_record_hdl ;
- {
- DialogPtr new_dialog ;
- int item_hit ;
- Handle hdl ;
- Rect box ;
- int type ;
- int had_data = FALSE ;
-
- if( ( cell.v ) != 0 && ( cell.h != 0 ) ) {
-
- HLock( (Handle)sheet_record_hdl ) ;
- new_dialog = GetNewDialog( ENTER_DATA_DIALOG, NULL, (WindowPtr)-1L ) ;
-
- /* Outline button */
- SetPort( new_dialog ) ;
- GetDItem( new_dialog, ENTER_BUTTON, &type, &hdl, &box ) ;
- PenNormal( ) ;
- PenSize( 3,3 ) ;
- InsetRect( &box, -4,-4 ) ;
- FrameRoundRect( &box, 16,16 ) ;
-
- GetDItem( new_dialog, DATA_ITEM, &type, &hdl, &box ) ;
-
- if( (**sheet_record_hdl).sheet_data[cell.v-1][cell.h-1].formula[0] != 0 ) {
- SetIText( hdl, (**sheet_record_hdl).sheet_data[cell.v-1][cell.h-1].formula ) ;
- SelIText( new_dialog, DATA_ITEM, 0, 255 ) ;
- had_data = TRUE ;
- }
-
- do{
- ModalDialog( NULL, &item_hit ) ;
- }while( item_hit == DATA_ITEM ) ;
-
- if( item_hit != CANCEL_BUTTON ) {
- GetIText( hdl, &(**sheet_record_hdl).sheet_data[cell.v-1][cell.h-1].formula ) ;
- SetType( &(**sheet_record_hdl).sheet_data[cell.v-1][cell.h-1], had_data ) ;
- calc_hdl = sheet_record_hdl ;
- calc_data = TRUE ;
- }
- CloseDialog( new_dialog ) ;
- HUnlock( (Handle)sheet_record_hdl ) ;
- }else{
- SysBeep( 1 ) ;
- }
- return ;
- }